#ifndef QLOGGER_H
#define QLOGGER_H

#define LOG_FILE	"log.txt"

#include <QFile>
#include <QString>
#include <QTextStream>
#include <QDateTime>

#define LOG_DEBUG	10
#define LOG_INFO	20
#define LOG_WARNING	30
#define LOG_ERROR	40

class QLogger
{
public:
	~QLogger();

	static QLogger* instance(quint8 lvl=0);
	void destroy();

	void trace(QString text,quint8 lvl);

private:
	QLogger(quint8 lvl);
	QString format(QString text);
	static QLogger* m_instance;
	static quint8 m_level;

};

#define __init(__LVL__)		QLogger::instance(__LVL__)
#define __debug(__TEXT__)	QLogger::instance()->trace(__TEXT__,LOG_DEBUG)
#define __info(__TEXT__)	QLogger::instance()->trace(__TEXT__,LOG_INFO)
#define __warning(__TEXT__)	QLogger::instance()->trace(__TEXT__,LOG_WARNING)
#define __error(__TEXT__)	QLogger::instance()->trace(__TEXT__,LOG_ERROR)

#endif // QLOGGER_H
